#!/usr/bin/perl -w
use strict;

my %keywords;
open IN, "data/zx110_keywords" or die("fail open data/zx110_keywords\n");
while (<IN>) {
	chomp;
	next if (length() < 3);
	$keywords{$_} = 0;
}
close IN;

my @fields = qw(web_homepage_title web_homepage_keywords web_homepage_description);
my $sql = 'select icp_home_page from domain_info where (';
foreach my $field (@fields) {
	foreach my $keyword (keys %keywords) {
		$sql .= "$field like '%$keyword%' or ";
	}
}
$sql = substr($sql, 0, length($sql) - 4);
$sql .= ") and ts > '$ARGV[0]'";
#print "$sql\n";
my $dump = `mysql -D zx110 -N -e "set names utf8; $sql" | perl -ne 'chomp;\@arr = split(",");foreach \$url (\@arr) {print "\$url\n" if (length(\$url) > 4)}' > data/zx110_export.txt`;

